<script setup lang="ts">
import { FillDTO } from '@/api/fill/business/Types';
import { ref } from 'vue';
import { getYear } from '@/hooks/useDate';
import { FillActFrom, FillManagementForm, FillManagementVO } from '@/api/fill/management/Types';
import {
  deleteFile,
  getApplyList,
  getFile,
  getFillActManageDetail,
  getListIssueAll,
  getListManage,
  getListManageAll,
  saveOrUpdateNew,
  submitAll,
  uploadFile,
  verify
} from '@/api/fill/management-two';
import { genFileId, UploadInstance, UploadProps, UploadRawFile } from 'element-plus';
import { ApplyVO } from '@/api/fill/apply/types';
import SubmitVerify from '@/components/Process/submitVerify.vue';
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
import { StartProcessBo } from '@/api/workflow/workflowCommon/types';
import { startWorkFlow } from '@/api/workflow/task';
import { format } from 'date-fns';
import { defaultDeptName, defaultYard, titleList } from '@/hooks/useCommon';
import { getFillDesc, getOldValue, getSumColumns, getSummaries, getTotal, highlightClass,useTableHeight } from '@/hooks/useMethod';
import { TableEnum } from '@/enums/business/TableEnum';
import { checkConfig } from '@/api/budget/actAdjustConfig';
import NoFillTwo from '@/views/fill/NoFillTwo.vue';
import IssuedDataDrawer from '@/components/IssuedDataDrawer/index.vue';

const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const loading = ref(true);
const showSearch = ref(true);
const { yard_type, approval_status } = toRefs<any>(proxy?.useDict('yard_type', 'approval_status'));
const buttonLoading = ref(false);
const queryFormRef = ref<ElFormInstance>();
//切换的标签
const yardType = ref(defaultYard);
// 使用示例
const tableStyle = useTableHeight(showSearch);
// 查询参数
const queryParams = ref<FillDTO>({
  year: getYear(),
  yardCode: yardType.value,
  deptCode: undefined,
  id: undefined //当前流程的主表id
});
const deptNameShow = ref(defaultDeptName);

const selectTab = (val: string) => {
  yardType.value = val;
  queryParams.value.yardCode = val;
  getManageFillList();
};
/**首页列表数据显示*/
const tableList = ref([]);

const tableIssueList = ref([]);
//重置表单
const reset = () => {
  type.value = 1;
  submitButtonShow.value = true;
  queryParams.value.id = undefined;
  form.value = null;
};
const type = ref(1);
const getListAll = (routeParams?: any) => {
  loading.value = true;
  if (routeParams) {
    //查询业务主表详情
    type.value = 2;
    getFillActManageDetail(routeParams.id)
      .then((res) => {
        deptNameShow.value = res.data.deptName;
        queryParams.value.year = format(new Date(res.data.year + '-01-01'), 'yyyy');
        queryParams.value.deptCode = res.data.deptCode;
        form.value = res.data;
        queryParams.value.id = res.data.id;
      })
      .then(() => {
        getListManageAll(queryParams.value).then((res) => {
          tableList.value = res.data;
        });
      })
      .finally(() => (loading.value = false));
    return;
  }
  //获得用户信息和提交表单信息
  reset();
  verify(queryParams.value)
    .then((res) => {
      let user = res.data.user;
      queryParams.value.deptCode = user.budgetDeptCode;
      deptNameShow.value = user.budgetDeptName;
      const actManageForm = res.data.actManageForm;
      if (actManageForm) {
        form.value = actManageForm;

        queryParams.value.id = actManageForm.id;
        // 对于填写的人来说，只有审核中，已完成的不可以提交
        if (form.value.status === 'waiting' || form.value.status === 'finish') {
          submitButtonShow.value = false;
        }
      }
    })
    .then(() => {
      getListManageAll(queryParams.value).then((res) => {
        tableList.value = res.data;
      });
      // console.log(queryParams.value);
    })
    .finally(() => (loading.value = false));
};

/** 搜索按钮操作 */
const handleQuery = () => {
  getListAll();
};

/** 重置按钮操作 */
const resetQuery = () => {
  queryParams.value.year = getYear();
  handleQuery();
};

/**上传取消*/
function cancel() {
  dialogFile.visible = false;
}

const dialog = reactive<DialogOption>({
  visible: false,
  title: ''
});

const dialogIssue = reactive<DialogOption>({
  visible: false,
  title: ''
});

const openClickIssue = () => {
  dialogIssue.title = '';
  dialogIssue.visible = true;
  loading.value = true;
  getListIssueAll(queryParams.value)
    .then((res) => {
      tableIssueList.value = res.data;
    })
    .finally(() => (loading.value = false));
};

/**填报弹窗按钮开关*/
const fillOut = () => {
  if (!queryParams.value.deptCode) {
    proxy?.$modal.msgError('暂无预算部门，不能填报！');
    return;
  }
  dialog.visible = true;
  dialog.title = '填报';
  getManageFillList();
};

const dialogFile = reactive<DialogOption>({
  visible: false,
  title: ''
});
/**--------------------------------------填报弹窗------------------------------------------------*/

/**填报列表数据*/
const list = ref<FillManagementVO[]>([]);

/**填报列表显示*/
const getManageFillList = async () => {
  await getListManage(queryParams.value)
    .then((res) => {
      list.value = res.data;
    })
    .finally(() => (loading.value = false));
};

/**填报表格*/
const fillForm = ref<FillManagementForm>({
  deptCode: undefined,
  deptName: undefined,
  yardCode: undefined,
  year: undefined,
  listTwo: []
});

const noShow = ref(false);

//赋值
function assignment() {
  fillForm.value.deptCode = queryParams.value.deptCode;
  fillForm.value.deptName = deptNameShow.value;
  fillForm.value.yardCode = queryParams.value.yardCode;
  fillForm.value.year = queryParams.value.year;
}

//保存数据
const submitData = async (type: number) => {
  /*提交数据 校验科目是否为空*/
  if (list.value.length === 0) {
    proxy?.$modal.msgError('一下的数据还未产生，请等待');
  }
  buttonLoading.value = true;
  if (type === 2) {
    noShow.value = true;
    buttonLoading.value = false;
  } else {
    noShow.value = false;
    //赋值
    assignment();
    // 从 list 中筛选出应显示的项并填充到 fillForm 的 list 属性中
    // fillForm.value.listTwo = list.value.filter(item => item.isShow === true);
    fillForm.value.listTwo = list.value;

    // 保存或更新表单数据
    await saveOrUpdateNew(fillForm.value)
      .then((res) => {
        // 更新查询参数中的id值
        queryParams.value.id = res.data;
        // 显示成功保存的提示信息
        proxy?.$modal.msgSuccess('保存成功');
      })
      .then(() => {
        // 重新加载数据
        getManageFillList();
      })
      .finally(() => (buttonLoading.value = false));
  }
};
const cancelClick = () => {
  dialog.visible = false;
  noShow.value = false;
  getListAll();
};

/** 归口统计科目- 明细列表*/
const showList = ref<ApplyVO[]>([]);
const openShowList = (row: FillManagementVO) => {
  getApplyList({
    year: queryParams.value.year,
    yardCode: yardType.value,
    subjectCode: row.subjectCode
  }).then((res) => {
    showList.value = res.data;
  });
};
/**--------------------------------------------------------文件-----------------------------------------------------------*/

const ossFormRef = ref<ElFormInstance>();
//选中的
const selectSubject = ref();
/** 文件按钮操作 */
const handleFile = (row?: any) => {
  if (!queryParams.value.id) {
    proxy?.$modal.msgError('请填报保存后，再进行上传！');
    return;
  }
  fileList.value = [];
  selectSubject.value = undefined;
  dialogFile.visible = true;
  dialogFile.title = '上传附件';
  selectSubject.value = row.subjectCode;
};

const fileList = ref<any[]>([]);
const selectedFile = ref<any>();
const beforeUpload = (file: File) => {
  const allowedExtensions = ['doc', 'xls', 'xlsx', 'ppt', 'pdf'];
  const fileExtension = file.name.substring(file.name.lastIndexOf('.'));
  if (!allowedExtensions.includes(fileExtension.toLowerCase())) {
    ElMessage.error('只允许上传文件（doc、xls、xlsx、ppt、pdf格式）');
    return false;
  }
  return true;
};
const handleFileChange = (file: any) => {
  // 存储选中的文件
  selectedFile.value = file;
};

const upload = ref<UploadInstance>();
const handleExceed: UploadProps['onExceed'] = (files) => {
  upload.value!.clearFiles();
  const file = files[0] as UploadRawFile;
  file.uid = genFileId();
  upload.value!.handleStart(file);
};

/**文件上传提交*/
const submitUpload = async () => {
  if (selectedFile.value) {
    const formData = new FormData();
    formData.append('file', selectedFile.value.raw);
    formData.append('year', queryParams.value.year.toString());
    formData.append('subjectCode', selectSubject.value);
    formData.append('actId', queryParams.value.id.toString());
    formData.append('deptCode', queryParams.value.deptCode.toString());
    await uploadFile(formData).then(() => {
      dialogFile.visible = false;
      ElMessage.success('上传成功');
      getListAll();
    });
  } else {
    ElMessage.error('请选择一个文件');
  }
};

// 打开文件连接
const handleViewFile = (row: any) => {
  getFile(row.ossId).then((res) => {
    window.open(res.data.url, '_blank');
  });
};
const handleDelete = async (row?: any) => {
  const ossId = row?.ossId;
  await proxy?.$modal.confirm('是否确认删除附件？');
  loading.value = true;
  await deleteFile(ossId).finally(() => (loading.value = false));
  getListAll();
  proxy?.$modal.msgSuccess('删除成功');
};

/** 下载按钮操作 */
const handleDownload = (row: any) => {
  proxy?.$download.oss(row.ossId);
};

/**--------------------------------------审批流集成-----------------------------------------------*/
const form = ref<FillActFrom>({
  id: undefined,
  deptCode: undefined,
  deptName: undefined,
  status: undefined,
  year: undefined
});

//提交审核
const submit = async () => {
  if (!queryParams.value.deptCode) {
    proxy?.$modal.msgError('暂无预算部门，不能提交！');
    return;
  }
  if (!queryParams.value.id) {
    proxy?.$modal.msgError('请填报保存后，再进行提交！');
    return;
  }
  form.value.year = queryParams.value.year;
  form.value.deptCode = queryParams.value.deptCode;
  form.value.deptName = deptNameShow.value;
  buttonLoading.value = true;

  submitAll(form.value)
    .then((res) => {
      form.value = res.data;
      handleStartWorkFlow(res.data);
    })
    .finally(() => (buttonLoading.value = false));
};
//路由参数
const routeParams = ref<Record<string, any>>({});
//提交组件
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
//审批记录组件
const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
const submitFormData = ref<StartProcessBo>({
  businessKey: '',
  tableName: '',
  variables: {}
});
const taskVariables = ref<Record<any, any>>({});
//提交申请
const handleStartWorkFlow = async (data: FillActFrom) => {
  try {
    //管理填报
    submitFormData.value.tableName = TableEnum.FILL_ACT_MANAGE_TWO;
    submitFormData.value.businessKey = data.id;
    //流程变量
    taskVariables.value = {
      entity: data,
      purchaseDeptName: '/',
      deptName: data.deptName
    };
    submitFormData.value.variables = taskVariables.value;
    await startWorkFlow(submitFormData.value).then((res) => {
      if (submitVerifyRef.value) {
        buttonLoading.value = false;
        submitVerifyRef.value.openDialog(res.data.taskId);
      }
    });
  } finally {
    buttonLoading.value = false;
  }
};
//审批记录
const handleApprovalRecord = () => {
  approvalRecordRef.value.init(form.value.id);
};
//提交回调
const submitCallback = async () => {
  if (type.value === 2) {
    //审批页面关闭页签
    await proxy.$tab.closePage(proxy.$route);
    proxy.$router.go(-1);
  } else {
    //填报页刷新列表
    getListAll();
  }
};

//审批
const approvalVerifyOpen = async () => {
  submitVerifyRef.value.openDialog(routeParams.value.taskId);
};

//校验提交按钮是否显示
const submitButtonShow = ref(true);

//校验审批按钮是否显示
const approvalButtonShow = computed(() => {
  return routeParams.value.type === 'approval' && form.value.status && form.value.status === 'waiting';
});

const show = ref(true);
const checkConfigFlag = ref(true);
onMounted(() => {
  checkConfig('2')
    .then((res) => {
      checkConfigFlag.value = res.data;
    })
    .then(() => {
      if (checkConfigFlag.value) {

        nextTick(() => {
          routeParams.value = proxy.$route.query;

          if (routeParams.value.type === 'view' || routeParams.value.type === 'approval') {
            //禁用编辑
            submitButtonShow.value = false;
            show.value = false;
            getListAll(routeParams.value);
          } else {
            show.value = true;
            getListAll();
          }
        });
      }
    });
});

/** 导出按钮操作 */
const handleExport = () => {
  proxy?.download(
    'fill-manage/export',
    {
      ...queryParams.value
    },
    `管理填报表.xlsx`
  );
};

// 获取计算列（使用computed保持响应式）
const sumColumns = computed(() => getSumColumns(yard_type.value, titleList));

// 在表格中使用
const tableSummaries = (param: any) => {
  return getSummaries(param, sumColumns.value);
};
</script>

<template>
  <div class="p-2" v-if="checkConfigFlag">
    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
      <div v-show="showSearch" class="mb-[10px]">
        <el-card shadow="never">
          <el-form ref="queryFormRef" :inline="true">
            <el-form-item label="年份" prop="year">
              <el-date-picker date-format="YYYY" value-format="YYYY" type="year" v-model="queryParams.year" :disabled="!show" />
            </el-form-item>
            <el-form-item label="预算部门" prop="deptCode" label-width="120px">
              <el-input disabled :placeholder="deptNameShow" />
            </el-form-item>
            <el-form-item v-if="show">
              <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </div>
    </transition>

    <el-card shadow="never">
      <template #header>
        <div style="display: flex; justify-content: space-between">
          <div>
            <el-button type="primary" plain icon="EditPen" @click="fillOut()" v-hasPermi="['fill:managementTwo:add']" v-if="submitButtonShow">
              填报
            </el-button>
            <el-button
              type="success"
              plain
              icon="Position"
              :loading="buttonLoading"
              @click="submit()"
              v-if="submitButtonShow"
              v-hasPermi="['fill:manageTwo:submit']"
            >
              提交
            </el-button>
            <el-button v-if="approvalButtonShow" :loading="buttonLoading" type="primary" @click="approvalVerifyOpen" icon="Promotion"
              >审批
            </el-button>
            <el-button
              v-if="form && form.id && form.status !== null && form.status !== 'draft'"
              type="primary"
              @click="handleApprovalRecord"
              icon="View"
            >
              流程进度
            </el-button>
            <el-button type="warning" plain icon="Download" @click="handleExport">导出</el-button>
            <el-button type="danger" plain icon="HelpFilled" @click="openClickIssue">查看下达数据</el-button>
            <span style="color: orangered; margin-left: 20px">【总计】：{{ getTotal(tableList) }} 万元</span>
          </div>
          <div v-if="show">
            <right-toolbar v-model:showSearch="showSearch" @queryTable="getListAll" />
          </div>
        </div>
      </template>
      <div>
        <el-table
          ref="tableRef"
          :data="tableList"
          :style="tableStyle"
          append
          :show-summary="true"
          :summary-method="tableSummaries"
          class="table-box-index enhanced-table"
        >
          <el-table-column prop="subjectCode" label="预算科目编码" v-if="false" align="center" />
          <el-table-column prop="subjectName" label="预算科目名称" width="250" align="center" fixed="left">
            <template #default="scope">
              <!--              <el-tooltip effect="dark" placement="top" :content="scope.row.subjectCode">-->
              <span class="font-class-red" v-if="scope.row.red">{{ scope.row.subjectName }}</span>
              <span v-else>{{ scope.row.subjectName }}</span>
              <!--              </el-tooltip>-->
            </template>
          </el-table-column>
          <el-table-column v-for="item in titleList" :key="item.key" :label="item.label" align="center">
            <el-table-column
              v-for="dict in yard_type"
              :key="dict.value"
              :label="dict.label"
              :prop="dict.value + '_' + item.key"
              align="center"
              min-width="160"
            >
              <template #default="scope">
                <div v-if="!scope.row.red">
                  <!-- 判断是否有备注 -->
                  <el-popover
                    v-if="getFillDesc(scope.row, dict.value, item.key) !== '无'"
                    :effect="'dark'"
                    placement="top"
                    :width="150"
                    trigger="hover"
                    :content="scope.row[dict.value + '_' + item.key + 'Desc']"
                  >
                    <template #reference>
                      <span>{{ scope.row[dict.value + '_' + item.key] }}</span>
                    </template>
                  </el-popover>
                  <!-- 无备注时直接显示内容 -->
                  <span v-else>{{ scope.row[dict.value + '_' + item.key] }}</span>
                </div>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="合计" align="center">
            <el-table-column
              v-for="dict in yard_type"
              :key="dict.value"
              :label="dict.label"
              :prop="dict.value + '_total'"
              align="center"
              show-overflow-tooltip
              width="170"
            >
              <template #default="scope">
                <span v-if="dict === yard_type[0]" style="color: #4876ff">{{ scope.row[dict.value + '_total'] }}</span>
                <span v-if="dict === yard_type[1]" style="color: #00bfff">{{ scope.row[dict.value + '_total'] }}</span>
              </template>
            </el-table-column>
            <el-table-column align="center" label="总合计" prop="total" show-overflow-tooltip width="170">
              <template #default="scope">
                <span style="color: #00ff00">{{ scope.row['total'] }}</span>
              </template>
            </el-table-column>
          </el-table-column>
          <el-table-column label="附件" align="center" prop="" class-name="small-padding fixed-width" fixed="right" width="150">
            <template #default="scope">
              <el-tooltip content="查看" placement="top" v-if="scope.row.ossId">
                <el-button type="success" circle link @click="handleViewFile(scope.row)">
                  <svg-icon icon-class="excel2" />
                </el-button>
              </el-tooltip>
              <el-tooltip content="上传" placement="top" v-if="!scope.row.ossId && type === 1">
                <el-button type="primary" circle link @click="handleFile(scope.row)">
                  <svg-icon icon-class="UploadRounded"  />
                </el-button>
              </el-tooltip>
              <el-tooltip content="下载" placement="top" v-if="scope.row.ossId">
                <el-button type="primary" circle link @click="handleDownload(scope.row)">
                  <svg-icon icon-class="SymbolsDownload" />
                </el-button>
              </el-tooltip>
              <el-tooltip content="删除" placement="top" v-if="scope.row.ossId && type === 1">
                <el-button type="danger" circle link @click="handleDelete(scope.row)">
                  <svg-icon icon-class="DeleteOutline" />
                </el-button>
              </el-tooltip>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
    <!-- 提交组件 -->
    <submitVerify ref="submitVerifyRef" :task-variables="taskVariables" @submit-callback="submitCallback" />
    <!-- 审批记录 -->
    <approvalRecord ref="approvalRecordRef" />
    <!-- 上传文件弹窗 -->
    <el-dialog v-model="dialogFile.visible" :title="dialogFile.title" style="width: 350px" append-to-body>
      <el-form ref="ossFormRef" :model="form" label-width="80px">
        <el-form-item label="文件：">
          <el-upload
            ref="upload"
            class="upload-demo"
            :limit="1"
            :auto-upload="false"
            :show-file-list="true"
            :before-upload="beforeUpload"
            :on-exceed="handleExceed"
            :file-list="fileList"
            :on-change="handleFileChange"
          >
            <template #trigger>
              <el-button type="primary">请选择文件</el-button>
            </template>
          </el-upload>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button :loading="buttonLoading" type="success" @click="submitUpload">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <!--  填报抽屉页-->
    <el-drawer v-model="dialog.visible" direction="ttb" :title="dialog.title" append-to-body size="100%" :with-header="false">
      <el-tabs v-model="yardType" class="demo-tabs" @tab-change="selectTab">
        <el-tab-pane v-for="dict in yard_type" :key="dict.value" :label="dict.label" :name="dict.value" />
        <el-card>
          <template #header>
            <div style="display: flex; justify-content: space-between">
              <div>
                <el-button type="primary" icon="Lock" @click="submitData(1)"> 保 存</el-button>
                <el-button type="success" icon="Unlock" @click="submitData(2)"> 编 辑</el-button>
                <span style="margin-left: 10px; color: red">*注：红色为归口统计项目</span>
              </div>
              <div>
                <el-button type="danger" @click="cancelClick" icon="Close">关闭</el-button>
              </div>
            </div>
          </template>
          <div>
            <el-table
              border
              stripe
              v-loading="loading"
              :data="list"
              :height="850"
              :highlight-current-row="true"
              class="table-box enhanced-table"
              header-cell-class-name="custom-header"
            >
              <el-table-column prop="subjectCode" label="预算科目编码" v-if="false" align="center" show-overflow-tooltip />
              <el-table-column prop="subjectName" label="预算科目" width="200" align="center" show-overflow-tooltip>
                <template #default="scope">
                  <div>
                    <div v-if="!scope.row.isShow">
                      <el-popover placement="bottom" :width="1000" trigger="click" class="font-class">
                        <template #reference>
                          <div class="font-class-red" @click="openShowList(scope.row)">
                            {{ scope.row.subjectName }}
                          </div>
                        </template>
                        <el-table :data="showList" border>
                          <el-table-column label="部门编号" align="center" prop="deptCode" />
                          <el-table-column label="部门名称" align="center" prop="deptName" min-width="80" show-overflow-tooltip />
                          <el-table-column label="申请主题" align="center" prop="applyTheme" width="150" show-overflow-tooltip />
                          <el-table-column label="申请金额" align="center" prop="applyMoney" width="120" />
                          <el-table-column label="状态" align="center" prop="status" width="80">
                            <template #default="scope">
                              <dict-tag :options="approval_status" :value="scope.row.status" />
                            </template>
                          </el-table-column>
                          <el-table-column label="季度" align="center" prop="quarterName" />
                          <el-table-column label="申请时间" align="center" prop="createTime" width="170" />
                        </el-table>
                      </el-popover>
                    </div>
                    <div v-else>{{ scope.row.subjectName }}</div>
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="第一季度" align="center">
                <el-table-column prop="first" label="金额" align="center">
                  <template #default="scope">
                    <el-input-number
                      v-if="scope.row.isShow ? noShow : false"
                      v-model="scope.row.first"
                      style="width: 100%"
                      :min="0.0"
                      :max="999999999.99"
                      :controls="false"
                    />
                  </template>
                </el-table-column>
                <el-table-column prop="firstDesc" label="备注" align="center" :stripe="true" show-overflow-tooltip>
                  <template #default="scope">
                    <el-input
                      v-if="scope.row.isShow ? noShow : false"
                      v-model="scope.row.firstDesc"
                      type="textarea"
                      class="input-common"
                      show-word-limit
                    />
                  </template>
                </el-table-column>
              </el-table-column>
              <el-table-column label="第二季度" align="center">
                <el-table-column prop="second" label="金额" align="center">
                  <template #default="scope">
                    <el-input-number
                      v-if="scope.row.isShow ? noShow : false"
                      v-model="scope.row.second"
                      :min="0.0"
                      :max="999999999.99"
                      :controls="false"
                      style="width: 100%"
                    />
                  </template>
                </el-table-column>
                <el-table-column prop="secondDesc" label="备注" align="center" :stripe="true" show-overflow-tooltip>
                  <template #default="scope">
                    <el-input
                      v-if="scope.row.isShow ? noShow : false"
                      v-model="scope.row.secondDesc"
                      type="textarea"
                      class="input-common"
                      show-word-limit
                    />
                  </template>
                </el-table-column>
              </el-table-column>

              <el-table-column label="第三季度" align="center">
                <el-table-column prop="third" label="金额" align="center">
                  <template #default="scope">
                    <el-input-number
                      v-if="scope.row.isShow ? noShow : false"
                      v-model="scope.row.third"
                      :min="0.0"
                      :max="999999999.99"
                      :controls="false"
                      style="width: 100%"
                    />
                  </template>
                </el-table-column>
                <el-table-column prop="thirdDesc" label="备注" align="center" :stripe="true" show-overflow-tooltip>
                  <template #default="scope">
                    <el-input
                      v-if="scope.row.isShow ? noShow : false"
                      v-model="scope.row.thirdDesc"
                      type="textarea"
                      class="input-common"
                      show-word-limit
                    />
                  </template>
                </el-table-column>
              </el-table-column>

              <el-table-column label="第四季度" align="center">
                <el-table-column prop="fourth" label="金额" align="center">
                  <template #default="scope">
                    <el-input-number
                      v-if="scope.row.isShow ? noShow : false"
                      v-model="scope.row.fourth"
                      :min="0.0"
                      :max="999999999.99"
                      :controls="false"
                      style="width: 100%"
                    />
                  </template>
                </el-table-column>
                <el-table-column prop="fourthDesc" label="备注" align="center" :stripe="true" show-overflow-tooltip>
                  <template #default="scope">
                    <el-input
                      v-if="scope.row.isShow ? noShow : false"
                      v-model="scope.row.fourthDesc"
                      type="textarea"
                      class="input-common"
                      show-word-limit
                    />
                  </template>
                </el-table-column>
              </el-table-column>
            </el-table>
          </div>
        </el-card>
      </el-tabs>
    </el-drawer>
    <!--  下达数据抽屉页 -->
    <IssuedDataDrawer
      v-model="dialogIssue.visible"
      title="管理下达列表"
      :table-data="tableIssueList"
      :title-list="titleList"
      :yard-type="yard_type"
      :loading="loading"
      :get-old-value="getOldValue"
      :highlight-class="highlightClass"
      note-color="#e10707"
    />
  </div>

  <div class="p-2" v-else>
    <NoFillTwo />
  </div>
</template>

<style scoped lang="scss">
@import '@/assets/styles/common-style';

.table-container {
  height: calc(100vh - 120px); /* 根据页面布局调整 */
}

/* 固定合计行 */
:deep(.el-table__footer-wrapper) {
  position: sticky;
  bottom: 0;
  background: #fff;
  z-index: 1000;
  box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.08);
}

/* 固定表头 */
:deep(.el-table__header-wrapper) {
  position: sticky;
  top: 0;
  z-index: 1001;
}

/* 调整滚动条位置 */
:deep(.el-table__body-wrapper) {
  scrollbar-width: thin;
  overflow-y: auto !important;
}
</style>
